package com.nx.vip.javacore.reflection;

import java.lang.reflect.Constructor;

public class SingleMain {

    public static void main(String[] args) throws Exception {

        SingleDemo instance = SingleDemo.getInstance();
        SingleDemo instance1 = SingleDemo.getInstance();
        System.out.println(instance == instance1);  //true

        Class<? extends SingleDemo> clazz = instance.getClass();
        Constructor<? extends SingleDemo> constructor = clazz.getDeclaredConstructor();
        constructor.setAccessible(true);
        SingleDemo instance2 = constructor.newInstance();

        System.out.println(instance==instance2); //false





    }
}
